<%--
  Created by IntelliJ IDEA.
  User: f
  Date: 2020/10/8
  Time: 8:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="user" class="com.media.bean.UserBean" >

</jsp:useBean>
<jsp:setProperty name="user" property="*"></jsp:setProperty>
<%
    Class.forName("com.mysql.jdbc.Driver");
    String url ="jdbc:mysql://127.0.0.1:3306/book?user=root&password=root";
    Connection connection=DriverManager.getConnection(url);
    Statement stmt=connection.createStatement();
    String sql="insert into user(username,password,gender,age) values('"+user.getUsername()+"','"+user.getPassword()+"',1,23)";
    //String sql= "delete from user where id=3";
    //String sql="update user set status=2 where id=1";
    int count=stmt.executeUpdate(sql);
    if(count==0){
        out.print("添加失败");
    }
    else{
        out.print("添加成功");
    }
%>

